package com.ffox.service.impl;

import com.ffox.entity.Teachers;
import com.ffox.mapper.SchoolTeacherMapper;
import com.ffox.service.SchoolTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Service
public class SchoolTeacherServiceImpl implements SchoolTeacherService {
    @Autowired
    private SchoolTeacherMapper schoolTeacherMapper;
    @Override
    public Integer addTeacher(Map<String, Object> params) {
        var authentication = SecurityContextHolder.getContext().getAuthentication();
        params.put("schoolNum", authentication.getPrincipal());
        params.put("status", 0);
        params.put("createdAt", LocalDateTime.now());
        System.out.println(params);
        return schoolTeacherMapper.addTeacher(params);
    }

    @Override
    public Integer updateTeacher(String teacherId,Map<String, Object> params) {
        return schoolTeacherMapper.updateTeacher(teacherId, params);
    }

    @Override
    public Integer deleteTeacher(String teacherId) {
        return schoolTeacherMapper.deleteTeacher(teacherId);
    }

    @Override
    public List<Teachers> getALlTeacherBySchoolId(String schoolNum) {
        return schoolTeacherMapper.getALlTeacherBySchoolId(schoolNum);
    }
}
